//
//  UISliderDemo.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/3/27.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit
import SnapKit

class UISliderDemo: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.gray
        let sliber:UISlider = UISlider()
        sliber.addTarget(self, action: #selector(funSlider(slider:)), for: .valueChanged)
        //设置滑块的取值范围
        sliber.maximumValue = 10
        sliber.minimumValue = 1
        //是否在滑块滑动时持续触发方法
        sliber.isContinuous = false
        
        self.view.addSubview(sliber)
        sliber.snp.makeConstraints { (maker) in
            maker.width.equalTo(280)
            maker.height.equalTo(40)
            maker.center.equalTo(self.view)
        }
        
        //设置滑动轴的颜色
        sliber.minimumTrackTintColor = UIColor.red
        sliber.maximumTrackTintColor = UIColor.green
        //设置滑块颜色
        sliber.thumbTintColor = UIColor.orange
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    func funSlider(slider:UISlider) -> Void {
        print(slider.value)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
